package com.ghost.view.login
{
	import com.ghost.UI.Ghost_Btn;
	import com.ghost.manager.Load_manager;
	import com.ghost.model.Configure_url;
	import com.ghost.model.Loading_data;
	import com.ghost.model.Object_pool;
	import com.ghost.view.Base_effect;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;

	/**
	 * 选择创建role 
	 * @author ghost
	 */	
	public class Select_role extends Base_effect
	{	
		private var back_out:Bitmap;
		private var back_over:Bitmap;
		private var login_out:Bitmap;
		private var input_bg:BitmapData;
		
		private var bg_mc:Global_pop_bg;//交互区域的背景
		private var mutual_container:Sprite;//交互容器
		private var w:Number=1000;
		private var h:Number=600;
		public function Select_role(role_bg_mc:Bitmap)
		{
			back_out = new Bitmap(Object_pool.loaded_obj_pool.get("login_ui").get("back_out"));
			back_over = new Bitmap(Object_pool.loaded_obj_pool.get("login_ui").get("back_over"));
			login_out = new Bitmap(Object_pool.loaded_obj_pool.get("login_ui").get("login_out"));
			input_bg = Object_pool.loaded_obj_pool.get("login_ui").get("input_bg");
			this.addChild(role_bg_mc);
			mutual_container = new Sprite();
			this.addChild(mutual_container);
			bg_mc = new Global_pop_bg(370,null,null,21);
			mutual_container.addChild(bg_mc);
			mutual_container.x = w/2-mutual_container.width/2;
			mutual_container.y = h/2-mutual_container.height/2;
			
			show_head(0);
			var login_btn:Ghost_Btn = new Ghost_Btn(new <Object>[login_out,login_out,login_out,login_out],login_Handler);
			mutual_container.addChild(login_btn);
			var back_btn:Ghost_Btn = new Ghost_Btn(new <Object>[back_out,back_over,back_out,back_out],back_Handler);
			mutual_container.addChild(back_btn);
			login_btn.x = mutual_container.width/2-login_btn.width;
			login_btn.y = mutual_container.height/2-login_btn.height/2;
			back_btn.x = mutual_container.width/2;
			back_btn.y = mutual_container.height/2-back_btn.height/2;
		}
		private function login_Handler(e:MouseEvent):void
		{
			this.dispatchEvent(new Event('role_end'));
		}
		private function back_Handler(e:MouseEvent):void
		{
			this.dispatchEvent(new Event('back'));
		}
		private function show_head(type:int):void
		{
			Load_manager.get_Instance().add(Configure_url.img_url+"login/role/role_head"+String(type)+".png",Loading_data.type_img,'头像',head_Handler);
			Load_manager.get_Instance().start();
		}
		private function head_Handler(data:*):void
		{
			mutual_container.addChild(data);
			data.x = mutual_container.width/2-data.width/2;
			data.y = 50;
			//data.x = 10
			trace(data.x,data.y)
		}
	}
}